define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feedback/index' + location.search,
                    // add_url: 'shop/add',
                    // edit_url: 'shop/edit',
                    // del_url: 'shop/del',
                    table: 'shop',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                commonSearch: true,
                showToggle: false,
                showColumns: false,
                showExport: false,
                exportDataType: false,
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('用户ID')},
                        {field: 'content', title: __('反馈内容')},
                        {field: 'images', title: __('反馈图片'), events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'reply', title: __('客户回复')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {
                            field: 'operate',
                            title: __('回复'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'reply',
                                    title: __('回复'),
                                    text: __('回复'),
                                    classname: 'btn btn-auth btn-xs btn-primary btn-dialog',
                                    extend:'data-area=["30%","30%"]',
                                    url: 'feedback/edit?ids={ids}'
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        cash: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});